import java.io.IOException;
import java.util.List;

import com.dc.free.db.model.CGoods;
import com.dc.free.db.model._MappingKit;
import com.dc.free.util.DruidPluginUtil;
import com.dc.free.util.ExcelUtil;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;

public class GoodsLoad {

	public static void main(String[] args) throws IOException {
		DruidPlugin dp = DruidPluginUtil.create();
		// 配置ActiveRecord插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
        arp.setDialect(DruidPluginUtil.getDialect());  //指定 Dialect
        _MappingKit.mapping(arp);
        dp.start();
        arp.start();
		
		List<List<List<String>>> dataAll = ExcelUtil.me.read("E:/my file/项目/鸿程义卖/goods.xlsx");
		if(dataAll.size() < 1) return;
		List<List<String>> data = dataAll.get(0);
		if(data.size() < 2) return;
		int i = 0;
		for(List<String> row: data) {
			i++;
			if(i==1) continue;
			CGoods goods = new CGoods();
			goods.setId(row.get(0).split("[.]")[0]);
			goods.setName(row.get(1));
			goods.setDetail(row.get(5));
			goods.setImage(row.get(2));
			goods.setIncrease(Integer.parseInt(row.get(4).split("[.]")[0]));
			goods.setPrice(Integer.parseInt(row.get(3).split("[.]")[0]));
			goods.setActionId("2");
			goods.setProvider(row.get(6));
			goods.setIncreaseRuleDetail(row.get(7));
			goods.save();
		}
	}

}
